<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%edivi_common_back_logs}}".
 *
 * @property int $id
 * @property int $edivi_credit_order_id
 * @property string $assurer_no
 * @property string $bank_type
 * @property string $org_code
 * @property string $busi_code
 * @property string $bank_code
 * @property string $plat_no
 * @property int $trans_type
 * @property string $opinion
 * @property string $to_api_data
 * @property string $resp_to_edivi_data
 * @property int $created_at
 * @property string $user_name 姓名
 * @property string $id_card 身份证号
 * @property string $materials
 * @property string $loan_result
 * @property string $lr_card_no 卡号
 * @property string $lr_loan_date 放款日期
 * @property string $lr_loan_stage_date 分期日期
 * @property string $lr_recstat BAM放款状态
 * @property string $lr_loan_info
 * @property string $lr_li_loan_amount 放款金额
 * @property string $lr_li_loan_account 放款账户
 * @property int $lr_li_loan_flag 金额标志
 * @property string $lr_li_firstamt 本金首付
 * @property string $lr_li_eachamt 本金每期
 * @property string $lr_li_feeamt 手续费总额
 * @property string $lr_li_eachpfee 每期手续费
 * @property string $lr_li_firstpfee 首期手续费
 * @property int $lr_li_eachdate 每期扣款日
 * @property string $lr_li_nextdate 下次扣款日期
 * @property string $lr_li_workdate 申请日期
 * @property string $lr_li_trxspot 交易场所
 *
 * @property EdiviCreditOrder $ediviCreditOrder
 */
class EdiviCommonBackLogs extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%edivi_common_back_logs}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['edivi_credit_order_id', 'assurer_no', 'bank_type', 'org_code', 'busi_code', 'bank_code', 'plat_no', 'trans_type', 'to_api_data', 'resp_to_edivi_data', 'created_at'], 'required'],
            [['edivi_credit_order_id', 'trans_type', 'created_at', 'lr_li_loan_flag', 'lr_li_eachdate'], 'integer'],
            [['opinion', 'to_api_data', 'resp_to_edivi_data', 'materials', 'loan_result', 'lr_loan_info'], 'string'],
            [['lr_li_loan_amount', 'lr_li_loan_account', 'lr_li_firstamt', 'lr_li_eachamt', 'lr_li_feeamt', 'lr_li_eachpfee', 'lr_li_firstpfee'], 'number'],
            [['assurer_no'], 'string', 'max' => 30],
            [['bank_type', 'org_code', 'bank_code', 'plat_no', 'lr_loan_date', 'lr_loan_stage_date'], 'string', 'max' => 20],
            [['busi_code', 'lr_li_nextdate', 'lr_li_workdate'], 'string', 'max' => 10],
            [['user_name', 'id_card'], 'string', 'max' => 50],
            [['lr_card_no', 'lr_recstat'], 'string', 'max' => 60],
            [['lr_li_trxspot'], 'string', 'max' => 100],
            [['edivi_credit_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviCreditOrder::className(), 'targetAttribute' => ['edivi_credit_order_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'edivi_credit_order_id' => Yii::t('app', 'Edivi Credit Order ID'),
            'assurer_no' => Yii::t('app', 'Assurer No'),
            'bank_type' => Yii::t('app', 'Bank Type'),
            'org_code' => Yii::t('app', 'Org Code'),
            'busi_code' => Yii::t('app', 'Busi Code'),
            'bank_code' => Yii::t('app', 'Bank Code'),
            'plat_no' => Yii::t('app', 'Plat No'),
            'trans_type' => Yii::t('app', 'Trans Type'),
            'opinion' => Yii::t('app', 'Opinion'),
            'to_api_data' => Yii::t('app', 'To Api Data'),
            'resp_to_edivi_data' => Yii::t('app', 'Resp To Edivi Data'),
            'created_at' => Yii::t('app', 'Created At'),
            'user_name' => Yii::t('app', '姓名'),
            'id_card' => Yii::t('app', '身份证号'),
            'materials' => Yii::t('app', 'Materials'),
            'loan_result' => Yii::t('app', 'Loan Result'),
            'lr_card_no' => Yii::t('app', '卡号'),
            'lr_loan_date' => Yii::t('app', '放款日期'),
            'lr_loan_stage_date' => Yii::t('app', '分期日期'),
            'lr_recstat' => Yii::t('app', 'BAM放款状态'),
            'lr_loan_info' => Yii::t('app', 'Lr Loan Info'),
            'lr_li_loan_amount' => Yii::t('app', '放款金额'),
            'lr_li_loan_account' => Yii::t('app', '放款账户'),
            'lr_li_loan_flag' => Yii::t('app', '金额标志'),
            'lr_li_firstamt' => Yii::t('app', '本金首付'),
            'lr_li_eachamt' => Yii::t('app', '本金每期'),
            'lr_li_feeamt' => Yii::t('app', '手续费总额'),
            'lr_li_eachpfee' => Yii::t('app', '每期手续费'),
            'lr_li_firstpfee' => Yii::t('app', '首期手续费'),
            'lr_li_eachdate' => Yii::t('app', '每期扣款日'),
            'lr_li_nextdate' => Yii::t('app', '下次扣款日期'),
            'lr_li_workdate' => Yii::t('app', '申请日期'),
            'lr_li_trxspot' => Yii::t('app', '交易场所'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCreditOrder()
    {
        return $this->hasOne(EdiviCreditOrder::className(), ['id' => 'edivi_credit_order_id']);
    }
}
